package Schedule::Chronic::Distributed::Constraint::Memory;

=head1 NAME

Schedule::Chronic::Distributed::Constraint::Memory - Memory usage constraint

=head1 SYNOPSIS

use Schedule::Chronic::Distributed::Constraint::Memory;

Schedule::Chronic::Distributed::Constraint::Memory->update;

=head1 DESCRIPTION

Constraint class for tracking memory usage on a node.

=head1 METHODS

=head2 update

Object method to update the current state of the constraint object

=cut

use Sys::Statistics::Linux qw();
use strict;
use Data::Dumper;

use base qw(Schedule::Chronic::Distributed::Constraint);
use constant _STATE => 1;

sub update {
    my $self = shift;
    my $obj = Sys::Statistics::Linux->new( MemStats => 1 );
    sleep(2);
    my $stats = $obj->get;
    $self->[_STATE] = $stats->{MemStats}{MemUsedPro} / 2;
    $self->update_last_time;
    return $self->[_STATE];
}


=head1 SEE ALSO

Schedule::Chronic::Distributed::Task

Schedule::Chronic::Distributed::Constraint

=head1 AUTHOR

aaron trevena, E<lt>aaron.trevena@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2006 by Aaron Trevena, Aviation Briefing Ltd

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.

=cut

1;
